using Dapper;
using SmartLink.Domain.Entity;
using SmartLink.EnumLibrary;
using SmartLink.IRepository;
using SmartLink.Repository.Base;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SmartLink.Repository
{
    public class PER_DataAuthorizationRepo : RepositoryBase<PER_DataAuthorization>, IPER_DataAuthorizationRepo
    {
        public IEnumerable<PER_DataAuthorization> GetDataAuthorization(AuthorizationOwnerTypeEnum ownerType, params int[] ownerIds)
        {
            var sql = $@"SELECT * FROM PER_DataAuthorization WHERE OwnerType={(int)ownerType} AND OwnerID IN ({string.Join(",", ownerIds)})";
            using (var conn = CreateConn())
            {
                return conn.Query<PER_DataAuthorization>(sql);
            }
        }
    }
}
